<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:mynounou="http://java.sun.com/jsf/composite/mynounou">
<h:head>
	<f:facet name="first">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
	</f:facet>

</h:head>
<body>
	<ui:composition template="/faces/template.xhtml">
		<ui:define name="content">
			<h:form id="form">
				<p:growl id="growl"></p:growl>
				<p:dialog visible="true" closable="false" header="Connexion"
					rendered="#{!ConnectionController.connected}" resizable="false">
					<p:panelGrid columns="2" style="border:none;">
						<p:outputLabel value="Identifiant :" for="username"></p:outputLabel>
						<p:inputText id="username"
							value="#{ConnectionController.username}"></p:inputText>
						<p:outputLabel value="Mot de passe :" for="password"></p:outputLabel>
						<p:password id="password" value="#{ConnectionController.password}" />
					</p:panelGrid>
					<f:facet name="footer">
						<p:commandButton value="Envoyer"
							action="#{ConnectionController.doConnect}" ajax="false">
						</p:commandButton>
					</f:facet>
				</p:dialog>
				<p:menubar rendered="#{ConnectionController.connected}">
					<p:submenu label="Menu">
						<p:menuitem value="Déconnexion"
							action="#{ConnectionController.doDisconnect}" update="form"
							rendered="#{ConnectionController.connected}"></p:menuitem>
					</p:submenu>
					<p:submenu label="Gestion">
						<p:submenu label="Enfants">
							<p:menuitem value="Ajouter un enfant"
								actionListener="#{ConnectionController.manageEnfants}"></p:menuitem>
						</p:submenu>
					</p:submenu>
				</p:menubar>


				<h:form>
					<p:dashboard id="board" model="#{ContratController.model}">
						<p:panel id="enfants" header="Enfants">
							<p:dataTable rendered="#{ConnectionController.connected}"
								var="enfant" value="#{ConnectionController.enfantsDataTable}"
								style="padding-top:20px;" rowKey="#{enfant.id}"
								selectionMode="single"
								selection="#{ConnectionController.selectedEnfant}">
								<f:facet name="header">Enfants</f:facet>
								<p:column headerText="Nom">
									<h:outputText value="#{enfant.nom}" />
								</p:column>
								<p:column headerText="Prénom">
									<h:outputText value="#{enfant.prenom}" />
								</p:column>
								<f:facet name="footer">
									<p:commandButton value="Ajouter"
										actionListener="#{ConnectionController.addEnfant}"></p:commandButton>
									<p:commandButton value="Modifier"></p:commandButton>
									<p:commandButton value="Effacer"></p:commandButton>
								</f:facet>
							</p:dataTable>
						</p:panel>

						<p:panel id="parents" header="Parents">
							<p:dataTable rendered="#{ConnectionController.connected}"
								var="p" value="#{ParentController.parents}"
								style="padding-top:20px;"
								>
								<f:facet name="header">Parents</f:facet>
								<p:column headerText="Nom">
									<h:outputText value="#{p.nom}" />
								</p:column>
								<p:column headerText="Prénom">
									<h:outputText value="#{p.prenom}" />
								</p:column>
								<f:facet name="footer">
								<p:commandButton value="Ajouter"
										actionListener="#{ParentController.add}"></p:commandButton>
									<p:commandButton value="Modifier"></p:commandButton>
									<p:commandButton value="Effacer"></p:commandButton>
								</f:facet>
							</p:dataTable>
						</p:panel>
						
						<p:panel id="contrats" header="Contrats">
							<p:dataTable rendered="#{ConnectionController.connected}"
								var="enfant" value="#{ConnectionController.enfantsDataTable}"
								style="padding-top:20px;" rowKey="#{enfant.id}"
								selectionMode="single"
								selection="#{ConnectionController.selectedEnfant}">
								<f:facet name="header">Contrats</f:facet>
								<p:column headerText="Nom">
									<h:outputText value="#{enfant.nom}" />
								</p:column>
								<p:column headerText="Prénom">
									<h:outputText value="#{enfant.prenom}" />
								</p:column>
								<f:facet name="footer">
									<p:commandButton value="Ajouter"
										actionListener="#{ConnectionController.addContrat}"></p:commandButton>
									<p:commandButton value="Modifier"></p:commandButton>
									<p:commandButton value="Effacer"></p:commandButton>
								</f:facet>
							</p:dataTable>
						</p:panel>
					</p:dashboard>
				</h:form>

				<p:dock rendered="#{ConnectionController.connected}">
					<p:menuitem value="Gestion des contrats"
						icon="images/Crystal_Clear_app_reminders.png"
						actionListener="#{ConnectionController.contrats}" />
				</p:dock>
			</h:form>
		</ui:define>
	</ui:composition>
</body>
</html>